/// 创建人： Created by zhaoint
/// 创建时间：Created by  on 2020/7/23.
///
/// 创建人： Created by zhaoint
/// 创建时间：Created by  on 2020/9/25.
///
/// gongzhonghao biglead
/// https://study.163.com/instructor/1021406098.htm
/// https://blog.csdn.net/zl18603543572
/// https://www.toutiao.com/c/user/token/MS4wLjABAAAAYMrKikomuQJ4d-cPaeBqtAK2cQY697Pv9xIyyDhtwIM/

/*
{
	"msg": "success",
	"code": 200,
	"data": [{
		"catId": 457,
		"categoryCode": "QUICK_PRACTICE_SUB",
		"categoryName": "快速练习",
		"categoryOrder": 1,
		"categrtyImg": null,
		"categoryParent": 423,
		"categoryLevel": 2,
		"categoryDayTime": 0,
		"mineId": 24,
		"subList": null
	}]
}
 */
class CategoryBean {
  ///一级分类数据
  String categoryName;
  String categoryCode;
  String parentCode;

  ///分类图片
  String categrtyImg;

  String permissions;

  ///二级分类数据
  List<CategoryItemBean> children;

  ///
  int categoryOrder;
  int catId;
  int categoryParent;
  int categoryLevel;
  int categoryDayTime;

  //机考使用
  String label;
  String value;

  //错题
  String categoryTwo;
  String categoryValue;
  int number;

  CategoryBean({this.categoryName, this.categoryCode});

  CategoryBean.fromJson2(Map<String, dynamic> map) {
    this.categoryName = map["simpleTile"];
    this.categoryCode = map["id"].toString();
  }

  CategoryBean.fromJson(Map<String, dynamic> map) {
    //一级分类数据
    this.categoryName = map["categoryName"];
    this.categoryCode = map["categoryCode"];
    this.parentCode = map["parentCode"];
    this.permissions = map["permissions"];
    this.categrtyImg = map["categrtyImg"];

    this.categoryTwo = map["categoryTwo"];
    this.categoryValue = map["categoryValue"];
    this.number = map["number"];

    this.label = map["label"];
    this.value = map["value"];

    //二级分类数据
    List list = map["children"];
    if (list == null) {
      list = map["subList"];
    }

    if (list != null) {
      children = [];
      list.forEach((element) {
        children.add(CategoryItemBean.fromJson(element));
      });
    }
  }
}

class CategoryItemBean {
  String categoryName;
  String categoryCode;
  String parentCode;
  String permissions;

  ///机考使用
  String label;
  String value;

  bool isSelect;

  ///二级分类数据
  List<CategoryItemBean> children;

  CategoryItemBean(
      {this.categoryName,
      this.categoryCode,
      this.parentCode,
      this.permissions,
      this.isSelect = false});

  CategoryItemBean.fromJson(Map<String, dynamic> map) {
    this.categoryName = map["categoryName"];
    this.categoryCode = map["categoryCode"];
    this.parentCode = map["parentCode"];
    this.permissions = map["permissions"];
    this.isSelect = false;
    this.label = map["label"];
    this.value = map["value"];

    List list = map["children"];
    if (list == null) {
      list = map["subList"];
    }

    if (list != null) {
      children = [];
      list.forEach((element) {
        children.add(CategoryItemBean.fromJson(element));
      });
    }
  }
}
